package com.javaspeak.concurrency.lock.custom.reentrant;

/**
 * A IncrementCounterCallable is executed by the ExecutorService. It runs in its
 * own thread and tries to double increment the Counter by calling
 * counter.getDoubleIncrement( int timeOutInMilliseconds ).
 * <p>
 * If the current value is 2 it tries to get 4.
 * <p>
 * The IncrementCounterCallable returns a CounterValue (this class) in a Future.
 * <p>
 * The CounterValue includes the counter value, a nano timestamp of when the
 * IncrementCounterCallable succeeded in getting the counter value and the
 * thread name.
 *
 * @author John Dickerson
 */
public final class CounterValue {

    private final int value;
    private final long nanoTimestamp;
    private final String threadName;


    public CounterValue( int value, long nanoTimestamp ){

        this.value = value;
        this.nanoTimestamp = nanoTimestamp;
        this.threadName = Thread.currentThread().getName();
    }


    public final int getValue() {

        return value;
    }


    public final long getNanoTimestamp() {

        return nanoTimestamp;
    }


    public final String getThreadName() {

        return threadName;
    }
}
